package cn.tedu.dao;

import cn.tedu.entity.Banner;
import cn.tedu.entity.Show;
import cn.tedu.utils.DBUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class ShowDao {
    public List<Show> findAll() {
        ArrayList<Show> list = new ArrayList<>();
        //获取连接
        try (Connection conn = DBUtils.getConn()){
            String sql = "select * from `show`";
            Statement s = conn.createStatement();
            ResultSet rs = s.executeQuery(sql);
            while(rs.next()){
                int id = rs.getInt(1);
                String url = rs.getString(2);
                String time = rs.getString(3);
                String intro = rs.getString(4);
                list.add(new Show(id,url,time,intro));
                System.out.println(list);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }
}
